package com.pengshun.modules.api.mapper;


import com.pengshun.modules.api.news.service.dto.CategoryDto;
import com.pengshun.modules.api.news.service.dto.NewsFlashDto;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface NewsFlashMapper {

    /**
     * 我的快讯列表
     * @param userId
     * @param status
     * @param page
     * @param size
     * @return
     */
    @Select("select * from ps_news_flash where user_id=#{userId} and status=#{status} order  by  news_flash_id desc limit #{page},#{size}")
    List<NewsFlashDto> myselfList(@Param("userId") Long userId, @Param("status") Integer status, @Param("page") Integer page, @Param("size") Integer size);

    /**
     * 查询快讯分类
     * @return
     */
    List<CategoryDto> findNewsFlashCategorys();

    /**
     * 快讯列表
     * @param status
     * @param page
     * @param size
     * @return
     */
    List<NewsFlashDto> findNewsFlashList(@Param("status") Integer status, @Param("page") Integer page, @Param("size") Integer size);

    /**
     * 查找相关快讯
     * @param type
     * @return
     */
    List<NewsFlashDto> findNewsFlashAboutList(@Param("type") String type, @Param("newsFlashId") Long newsFlashId);

    @Select("SELECT nf.*,su.`avatar_name`userImage ,su.`nick_name` userName FROM ps_news_flash nf " +
            "LEFT JOIN sys_user su  ON su.`user_id`=nf.`user_id` WHERE nf.`news_flash_id`=#{newsFlashId}")
    NewsFlashDto findById(@Param("newsFlashId") Long newsFlashId);
}
